// node-rsa 密码解密
const NodeRSA = require("node-rsa");
const _priKey = `-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQC7XbcyVcZWN5idGVcl+TQCljUpSJnS5AIyZcDQqEBNRGxHxo2l
DfNlpcHktmgotu0hGC5qrWdET3UdaBi4qXuQ8x1fX9zY9QqwczNW5t8dnGvhrmIl
2QQ2wR8IB6jtwBmISdk7Snr0UgJc4tgXMoolPiaW631xKnwvbK4fCYZfVQIDAQAB
AoGASAuRFdnFmgFmvYGw8PkR9qyrZGR2QZFLBvX5XkJT92IIANFoRb9HiB5kn/1D
r+Qm6kLSFlL3El07O0N7vgXtbPacuUV2Ftqx7BYg1gWFvUQRTiKQLfLTRQAkbxZ+
mAltEJLle0iFh75RBKKjxeU0JCVHTIFG1vgGwzCW3wKXa0ECQQDeFHUA1Ie6jPAk
p9kBiKaVd+TK5Div61ZphGG3Zqjmp3ehdxlIDxvg4+/05tU2ad+NFW3bkmU41UbJ
pwzk7yffAkEA1/vp3IUFzVaCn1u+haUbF7WM3Ag+EyRWT7TTjRJ/SD7tD9wOXMj6
X6NaXN8hD4dj1A8xGh/JzUQiGeeK0FRvSwJAF/szi0xn/8Aaaorphx3fh0J0JWix
qmWKZkiSWMCwOoAZDgmTZFGlXAqhLdwDaCXUqyKGQ3Cyl4mIZFwyq0IcFwJATi2n
JuUXho3r1hb1TZbHybszc2mgXnlmrI89i/DIFbSBRp5WrIsq5XdRfBBf/Sj6n4Wo
NlaPSzeASHQhMOt/JQJBAIjdKy5dxLUyKL1J3URJZ5s6lG2xwkdD2EfgP9olNoGK
/6IioYZPRPf9Uid2ztlPWchl3LK0VDy/BZ/XdBaFzq4=
-----END RSA PRIVATE KEY-----
`

// 解密
const jsencrypt = {
    decrypt(password) {
        const privateKey = new NodeRSA(_priKey,);
        privateKey.setOptions({ encryptionScheme: "pkcs1" }); // 因为vue中使用jsencrypt，jsencrypt自身使用的是pkcs1加密方案, nodejs需要修改成pkcs1。
        var res = privateKey.decrypt(password, "utf8");
        return res;
    },
};

module.exports = jsencrypt;
